package com.liusp.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.liusp.entity.Result;
import com.liusp.pojo.OrderSetting;
import com.liusp.service.OrderSettingService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ordersetting")
public class OrderSettingController {
    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 根据日期修改可预约人数
     * @return 结果
     */
    @RequestMapping("/editNumberByDate.do")
    public Result editNumberByDate(@RequestBody OrderSetting orderSetting){
        try {
            orderSettingService.editNumberByDate(orderSetting);
        } catch (Exception e) {
            return new Result(false,"修改可预约人数失败");
        }
        return new Result(true,"修改可预约人数成功");
    }


    /**
     * 根据当前页面对应的月份查询预约设置信息
     * @param date 日期
     * @return 结果
     */
    @RequestMapping("/getOrderSettingByMonth.do")
    public Result getOrderSettingByMonth(@RequestParam("date") String date){
        return new Result(true,"成功",orderSettingService.getOrderSettingByMonth(date));
    }
}
